<template>
  <div>
    <el-form :model="queryParam" :inline=true style="display: flex">
      <el-form-item label="用户id">
        <el-input v-model="queryParam.userId" style="width:160px"/>
      </el-form-item>
      <el-form-item label="折扣率">
        <el-input v-model="queryParam.benift" style="width:160px"/>
      </el-form-item>
      <el-form-item label="商品名字">
        <el-input v-model="queryParam.goodsName" style="width:160px"/>
      </el-form-item>
      <el-form-item label="asin">
        <el-input v-model="queryParam.asin" style="width:160px"/>
      </el-form-item>
      <el-form-item label="链接">
        <el-input v-model="queryParam.link" style="width:160px"/>
      </el-form-item>
      <el-form-item label="促销码">
        <el-input v-model="queryParam.promoteCode" style="width:160px"/>
      </el-form-item>
      <el-form-item label="促销code">
        <el-input v-model="queryParam.couponCode" style="width:160px"/>
      </el-form-item>
      <el-form-item label="跟踪名">
        <el-input v-model="queryParam.trackName" style="width:160px"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="queryPage">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="tableData" stripe style="width: 100%">
      <el-table-column prop="id" label="序号" width="80"></el-table-column>
      <el-table-column prop="userId" label="用户id" width="80"></el-table-column>
      <el-table-column prop="benift" label="折扣率" width="80"></el-table-column>
      <el-table-column prop="goodsName" label="商品名字" width="120"></el-table-column>
      <el-table-column prop="asin" label="asin" width="120"></el-table-column>
      <el-table-column prop="link" label="链接" width="120"></el-table-column>
      <el-table-column prop="promoteCode" label="促销码" width="120"></el-table-column>
      <el-table-column prop="couponCode" label="促销code" width="120"></el-table-column>
      <el-table-column prop="trackName" label="跟踪名" width="120"></el-table-column>
      <el-table-column prop="createTime" label="创建时间" width="160">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="request" label="请求参数">
        <template slot-scope="scope">
          <div class="typeEnter">{{ scope.row.request  | ellipsis }}</div>
        </template>
      </el-table-column>
      <el-table-column prop="response" label="响应参数">
        <template slot-scope="scope">
          <div class="typeEnter">{{ scope.row.response  | ellipsis }}</div>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="pageTotal>0"
      :total="pageTotal"
      :page.sync="queryParam.pageNum"
      :limit.sync="queryParam.pageSize"
      @pagination="queryPage"
    />
  </div>
</template>

<script>
import {ellipsis, parseTime} from '@/utils'

export default {
  data() {
    return {
      // 查询参数
      pageTotal: 0,
      queryParam: {
        userId: '',
        benift: '',
        goodsName: '',
        asin: '',
        link: '',
        promoteCode: '',
        couponCode: '',
        trackName: '',
        pageNum: 1,
        pageSize: 10
      },
      tableData: []
    }
  },
  mounted() {
    this.pageList()
  },
  methods: {
    ellipsis,
    parseTime,
    queryPage() {
      var _this = this
      _this.pageList()
    },
    pageList() {
      var _this = this
      this.$api.promoteDetailPageList(_this.queryParam).then(res => {
        if (res.code === '00000') {
          _this.tableData = res.data.pageList
          _this.pageTotal = res.data.pageTotal
        } else {
          _this.$message(res.msg)
        }
      }).catch(e => {
        console.log('接口访问异常!')
      })
    }
  },
  filters: {
    ellipsis: (str) => ellipsis(str, 300)
  }
}
</script>
